package com.oaker.web.controller.hour;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.oaker.common.annotation.Log;
import com.oaker.common.core.controller.BaseController;
import com.oaker.common.core.domain.AjaxResult;
import com.oaker.common.core.page.TableDataInfo;
import com.oaker.common.enums.BusinessType;
import com.oaker.hours.doman.dto.PsersonTreandDTO;
import com.oaker.hours.doman.dto.UserHourSaveDTO;
import com.oaker.hours.doman.entity.SysPersonTrend;
import com.oaker.hours.doman.vo.PersonTreandVO;
import com.oaker.hours.service.SysPersonTrendService;
import com.oaker.hours.service.impl.MhHourDetailServiceImpl;
import com.oaker.hours.service.impl.MhUserHourServiceImpl;
import com.oaker.hours.service.impl.SysPersonTrendServiceImpl;
import com.oaker.hours.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

/**
 * Author: gaoyan
 * Date: 2021/10/26 23:54
 * Desc:oaker-project-master
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/mh/trend")
public class PersonTerandController extends BaseController {


    @Autowired
    SysPersonTrendServiceImpl personTrendService;



    /**
     * 查询人员动向信息
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('system:project:list')")
    public TableDataInfo list(PersonTreandVO vo) {
        log.info("Accept a connection on /mh/trend/list the params is:"+vo.toString());
        Page page = getPage();
        TableDataInfo sysPersonTrends = personTrendService.selectUserTreandVo(vo,page.getPageStart(), page.getPageSize());
        return sysPersonTrends;
    }




    /**
     * 用户批量填报动向
     */
    @PostMapping("/create/batch")
    @PreAuthorize("@ss.hasPermi('mh:hour:add')")
    @Log(title = "用户工时批量填报", businessType = BusinessType.INSERT)
    public AjaxResult createBatch(@Valid @RequestBody List<PsersonTreandDTO> PsersonTreandDTO) {

        boolean flage = personTrendService.createBatch(PsersonTreandDTO);

        return AjaxResult.success();

    }

}
